package com.blog.service.impl;

import com.blog.mapper.FollowMapper;
import com.blog.pojo.ResultResponse;
import com.blog.pojo.User;
import com.blog.service.FollowService;
import com.blog.utils.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FollowServiceImpl implements FollowService {
    @Autowired
    private FollowMapper followMapper;

    @Override
    public List<User> listFocusById() {
        int id = Integer.parseInt(UserContext.getUserId());
        List<User> userList = followMapper.listFocusById(id);
        return userList;
    }

    @Override
    public List<User> listFollowsById() {
        int id = Integer.parseInt(UserContext.getUserId());
        List<User> userList = followMapper.listFollowsById(id);
        return userList;
    }

    @Override
    public void insertFollow(Integer userId) {
        int id = Integer.parseInt(UserContext.getUserId());
        followMapper.insertFollow(userId, id);
    }

    @Override
    public void deleteFollow(Integer userId) {
        int id = Integer.parseInt(UserContext.getUserId());
        followMapper.deleteFollow(userId, id);
    }
}
